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

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

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

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

c = A("c")
g = B("g")
b = C("b")
e = D("e")
m = A("m")
i = C("i")

c.y = g
c.w = g
c.q = m
g.t = m
g.o = m
g.p = m
b.u = c
b.y = m
b.s = i
e.q = g
e.w = c
e.y = i
m.y = g
m.w = g
m.q = c
i.u = m
i.y = c
i.s = b
assert e.q.p.w.t.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.w: B = None
        self.q: A = None
        self.txt = txt

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

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

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

c = A("c")
g = B("g")
b = C("b")
e = D("e")
m = A("m")
i = C("i")

c.y = g
c.w = g
c.q = m
g.t = m
g.o = m
g.p = m
b.u = c
b.y = m
b.s = i
e.q = g
e.w = c
e.y = i
m.y = g
m.w = g
m.q = c
i.u = m
i.y = c
i.s = b
assert e.q.p.w.t.y.txt == "g"