class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.o: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.t: B = None
        self.s: B = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.u: A = None
        self.q: C = None
        self.x: A = None
        self.r: A = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.s: B = None
        self.w: B = None
        self.x: D = None
        self.q: D = None
        self.txt = txt

a = A("a")
h = B("h")
l = C("l")
n = D("n")
m = C("m")
b = A("b")
c = D("c")
d = B("d")
j = B("j")

a.s = d
a.o = n
h.t = d
h.s = d
l.u = b
l.q = m
l.x = a
l.r = a
n.s = d
n.w = h
n.x = c
n.q = c
m.u = a
m.x = a
m.r = a
m.q = l
b.s = j
b.o = c
c.s = d
c.w = h
c.x = n
c.q = n
d.t = h
d.s = h
j.t = h
j.s = h
assert d.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.o: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.t: B = None
        self.s: B = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.u: A = None
        self.q: C = None
        self.x: A = None
        self.r: A = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.s: B = None
        self.w: B = None
        self.x: D = None
        self.q: D = None
        self.txt = txt

a = A("a")
h = B("h")
l = C("l")
n = D("n")
m = C("m")
b = A("b")
c = D("c")
d = B("d")
j = B("j")

a.s = d
a.o = n
h.t = d
h.s = d
l.u = b
l.q = m
l.x = a
l.r = a
n.s = d
n.w = h
n.x = c
n.q = c
m.u = a
m.x = a
m.r = a
m.q = l
b.s = j
b.o = c
c.s = d
c.w = h
c.x = n
c.q = n
d.t = h
d.s = h
j.t = h
j.s = h
assert d.t.t.t.txt == "h"