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

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

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

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

j = A("j")
c = B("c")
g = C("g")
k = D("k")

j.t = c
j.v = c
j.p = g
j.u = k
c.v = k
g.r = j
g.x = j
g.v = k
k.v = c
k.z = c
k.p = g
assert j.u.p.x.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.v: B = None
        self.p: C = None
        self.u: D = None
        self.txt = txt

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

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

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

j = A("j")
c = B("c")
g = C("g")
k = D("k")

j.t = c
j.v = c
j.p = g
j.u = k
c.v = k
g.r = j
g.x = j
g.v = k
k.v = c
k.z = c
k.p = g
assert j.u.p.x.txt == "j"