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

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

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

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

f = A("f")
n = B("n")
c = C("c")
i = D("i")
j = B("j")
g = B("g")

f.p = c
n.o = f
n.v = j
c.u = i
c.p = g
c.y = g
i.q = c
i.s = c
i.t = g
i.x = f
j.o = f
j.v = g
g.o = f
g.v = j
assert f.p.p.o.p.u.s.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

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

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

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

f = A("f")
n = B("n")
c = C("c")
i = D("i")
j = B("j")
g = B("g")

f.p = c
n.o = f
n.v = j
c.u = i
c.p = g
c.y = g
i.q = c
i.s = c
i.t = g
i.x = f
j.o = f
j.v = g
g.o = f
g.v = j
assert f.p.p.o.p.u.s.txt == "c"