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

class B:
    def __init__(self, txt: str):
        self.z: B = None
        self.u: A = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

e = A("e")
a = B("a")
j = C("j")
f = D("f")
g = B("g")

e.v = f
e.p = j
a.z = g
a.u = e
j.v = f
j.w = g
f.t = g
g.z = a
g.u = e
assert j.v.t.u.txt == "
class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.p: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.z: B = None
        self.u: A = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

e = A("e")
a = B("a")
j = C("j")
f = D("f")
g = B("g")

e.v = f
e.p = j
a.z = g
a.u = e
j.v = f
j.w = g
f.t = g
g.z = a
g.u = e
assert j.v.t.u.txt == "e"