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

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

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

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

class E:
    def __init__(self, txt: str):
        self.t: D = None
        self.y: A = None
        self.z: A = None
        self.txt = txt

c = A("c")
f = B("f")
i = C("i")
g = D("g")
e = E("e")
h = D("h")
b = B("b")
j = B("j")

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

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

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

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

class E:
    def __init__(self, txt: str):
        self.t: D = None
        self.y: A = None
        self.z: A = None
        self.txt = txt

c = A("c")
f = B("f")
i = C("i")
g = D("g")
e = E("e")
h = D("h")
b = B("b")
j = B("j")

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