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

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

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

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

i = A("i")
m = B("m")
h = C("h")
d = D("d")
g = C("g")
a = A("a")
c = B("c")

i.p = h
i.o = h
i.r = d
m.w = g
m.q = d
h.v = g
d.y = h
g.v = h
a.p = g
a.o = g
a.r = d
c.w = g
c.q = d
assert d.y.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.r: D = None
        self.o: C = None
        self.txt = txt

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

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

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

i = A("i")
m = B("m")
h = C("h")
d = D("d")
g = C("g")
a = A("a")
c = B("c")

i.p = h
i.o = h
i.r = d
m.w = g
m.q = d
h.v = g
d.y = h
g.v = h
a.p = g
a.o = g
a.r = d
c.w = g
c.q = d
assert d.y.v.v.txt == "h"