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

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

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

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

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

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

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

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

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

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

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