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

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

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

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

g = A("g")
a = B("a")
c = C("c")
e = D("e")
b = C("b")
j = D("j")
k = C("k")
d = A("d")
h = C("h")

g.o = j
a.y = c
c.p = j
c.r = b
e.w = g
e.y = j
e.q = j
e.o = a
b.p = j
b.r = c
j.w = g
j.y = e
j.q = e
j.o = a
k.p = e
k.r = c
d.o = e
h.p = e
h.r = b
assert h.p.y.q.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.txt = txt

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

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

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

g = A("g")
a = B("a")
c = C("c")
e = D("e")
b = C("b")
j = D("j")
k = C("k")
d = A("d")
h = C("h")

g.o = j
a.y = c
c.p = j
c.r = b
e.w = g
e.y = j
e.q = j
e.o = a
b.p = j
b.r = c
j.w = g
j.y = e
j.q = e
j.o = a
k.p = e
k.r = c
d.o = e
h.p = e
h.r = b
assert h.p.y.q.o.txt == "a"