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

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

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

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

i = A("i")
f = B("f")
g = C("g")
d = D("d")
h = C("h")
c = D("c")
a = B("a")
b = B("b")
j = C("j")

i.p = j
i.t = j
f.o = b
f.z = h
g.r = c
g.s = i
g.p = h
d.q = i
d.o = c
d.s = h
h.r = d
h.s = i
h.p = j
c.q = i
c.o = d
c.s = g
a.o = b
a.z = g
b.o = a
b.z = g
j.r = c
j.s = i
j.p = g
assert d.o.q.t.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.t: C = None
        self.txt = txt

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

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

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

i = A("i")
f = B("f")
g = C("g")
d = D("d")
h = C("h")
c = D("c")
a = B("a")
b = B("b")
j = C("j")

i.p = j
i.t = j
f.o = b
f.z = h
g.r = c
g.s = i
g.p = h
d.q = i
d.o = c
d.s = h
h.r = d
h.s = i
h.p = j
c.q = i
c.o = d
c.s = g
a.o = b
a.z = g
b.o = a
b.z = g
j.r = c
j.s = i
j.p = g
assert d.o.q.t.txt == "j"