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

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

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

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

h = A("h")
g = B("g")
n = C("n")
i = D("i")

h.r = n
h.z = n
g.p = n
g.w = n
g.x = h
g.t = i
n.q = h
n.t = i
i.t = h
assert h.r.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.z: C = None
        self.txt = txt

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

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

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

h = A("h")
g = B("g")
n = C("n")
i = D("i")

h.r = n
h.z = n
g.p = n
g.w = n
g.x = h
g.t = i
n.q = h
n.t = i
i.t = h
assert h.r.t.t.txt == "h"