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

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

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

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

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

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

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

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

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

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

b.t = a
b.s = c
b.v = c
b.p = f
d.y = m
d.s = a
d.q = e
d.o = b
c.s = b
f.y = c
a.t = b
a.s = m
a.v = m
a.p = f
h.s = a
e.y = c
e.s = a
e.q = d
e.o = b
m.s = b
assert c.s.t.p.y.txt == "c"