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

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

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

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

a = A("a")
f = B("f")
i = C("i")
h = D("h")
l = A("l")
e = D("e")
d = D("d")
j = A("j")

a.s = i
a.u = d
f.p = j
f.t = h
i.p = f
i.r = d
i.o = d
h.p = e
h.q = j
h.x = i
l.s = i
l.u = d
e.p = d
e.q = a
e.x = i
d.p = e
d.q = a
d.x = i
j.s = i
j.u = d
assert f.p.u.q.u.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.u: D = None
        self.txt = txt

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

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

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

a = A("a")
f = B("f")
i = C("i")
h = D("h")
l = A("l")
e = D("e")
d = D("d")
j = A("j")

a.s = i
a.u = d
f.p = j
f.t = h
i.p = f
i.r = d
i.o = d
h.p = e
h.q = j
h.x = i
l.s = i
l.u = d
e.p = d
e.q = a
e.x = i
d.p = e
d.q = a
d.x = i
j.s = i
j.u = d
assert f.p.u.q.u.txt == "d"