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

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

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

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

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

j.v = n
j.w = f
f.x = j
f.p = j
c.o = n
c.u = n
c.r = j
c.p = f
n.r = j
n.u = j
a.o = n
a.u = n
a.r = j
a.p = f
assert f.p.v.r.txt == "
class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.w: B = None
        self.txt = txt

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

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

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

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

j.v = n
j.w = f
f.x = j
f.p = j
c.o = n
c.u = n
c.r = j
c.p = f
n.r = j
n.u = j
a.o = n
a.u = n
a.r = j
a.p = f
assert f.p.v.r.txt == "j"