class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.u: C = None
        self.s: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: A = None
        self.q: A = None
        self.t: B = None
        self.v: D = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

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

h = A("h")
k = B("k")
f = C("f")
d = D("d")
c = A("c")
m = B("m")
e = D("e")
b = D("b")

h.t = c
h.u = f
h.s = b
k.x = h
k.q = h
k.t = m
k.v = e
f.r = m
d.r = c
d.p = c
d.t = h
d.o = k
c.t = h
c.u = f
c.s = d
m.x = c
m.q = c
m.t = k
m.v = e
e.r = h
e.t = h
e.o = k
e.p = c
b.r = h
b.t = c
b.p = c
b.o = k
assert k.x.u.r.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.u: C = None
        self.s: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: A = None
        self.q: A = None
        self.t: B = None
        self.v: D = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

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

h = A("h")
k = B("k")
f = C("f")
d = D("d")
c = A("c")
m = B("m")
e = D("e")
b = D("b")

h.t = c
h.u = f
h.s = b
k.x = h
k.q = h
k.t = m
k.v = e
f.r = m
d.r = c
d.p = c
d.t = h
d.o = k
c.t = h
c.u = f
c.s = d
m.x = c
m.q = c
m.t = k
m.v = e
e.r = h
e.t = h
e.o = k
e.p = c
b.r = h
b.t = c
b.p = c
b.o = k
assert k.x.u.r.txt == "m"